package com.ruoyi.web.controller.fireman;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.fireman.domain.TImagePosition;
import com.ruoyi.fireman.service.ITImagePositionService;
import com.ruoyi.fireman.service.ITMenuService;
import com.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * 首页菜单Controller
 *
 * @author ruoyi
 * @date 2021-08-24
 */
@Controller
@RequestMapping("/website/html")
public class WebsiteController extends BaseController {
    private String prefix = "fireman/website/html";

    @Autowired
    private ITMenuService tMenuService;
    @Autowired
    private ISysConfigService configService;
    @Autowired
    private ITImagePositionService itImagePositionService;

    /**
     * 官网首页
     */
    @GetMapping("/home")
    public String home(ModelMap mmap) {
        List<String> positions = new ArrayList<>();
        //获取公司参数
        mmap.put("companyName", configService.selectConfigByKey("fireman.companyName"));
        mmap.put("companyPhone", configService.selectConfigByKey("fireman.companyPhone"));
        mmap.put("companyAddress", configService.selectConfigByKey("fireman.companyAddress"));
        mmap.put("companyICP", configService.selectConfigByKey("fireman.companyICP"));
        //网站首页菜单与链接
        positions.add("1");
        positions.add("2");
        positions.add("3");
        positions.add("4");
        positions.add("5");
        positions.add("6");
        mmap.put("oneMenus", tMenuService.selectOneTMenuList(positions));
        //协会动态
        mmap.put("oneMenus2", tMenuService.selectTMenus("7").get(0));
        //监管动态
        mmap.put("oneMenus3", tMenuService.selectTMenus("8", "9", "10"));
        //会员名录
        mmap.put("oneMenus4", tMenuService.selectTMenus("11", "12", "13"));
        //视频展示
        mmap.put("oneMenus5", tMenuService.selectTMenus("14", "15", "16"));
        //友情链接
        positions.clear();
        positions.add("17");
        mmap.put("link", tMenuService.selectOneTMenuList(positions).get(0));


        //图片与链接
        TImagePosition tImagePosition = new TImagePosition();
        tImagePosition.setPosition("0");
        //浮动图片
        mmap.put("image_0", itImagePositionService.selectTImagePositionList(tImagePosition));
        //顶部logo图片
        tImagePosition.setPosition("1");
        mmap.put("image_1", itImagePositionService.selectTImagePositionList(tImagePosition));
        //二维码图片
        tImagePosition.setPosition("2");
        mmap.put("image_2", itImagePositionService.selectTImagePositionList(tImagePosition));
        //顶部轮播banner图
        tImagePosition.setPosition("3-");
        mmap.put("image_3", itImagePositionService.selectTImagePositionListLikePosition(tImagePosition));
        //登录框左边的轮播banner图片
        tImagePosition.setPosition("4-");
        mmap.put("image_4", itImagePositionService.selectTImagePositionListLikePosition(tImagePosition));
        //专题报道
        tImagePosition.setPosition("5");
        mmap.put("image_5", itImagePositionService.selectTImagePositionList(tImagePosition));
        return prefix + "/home";
    }

    /**
     * 官网首页
     */
    @GetMapping("/associety")
    public String associety(ModelMap mmap) {
        return prefix + "/associety";
    }

    /**
     * 官网首页
     */
    @GetMapping("/vipPerson")
    public String vipPerson(ModelMap mmap) {
        return prefix + "/vipPerson";
    }

    /**
     * 官网首页
     */
    @GetMapping("/newsInfo")
    public String newsInfo(ModelMap mmap) {
        return prefix + "/newsInfo";
    }

    /**
     * 官网首页
     */
    @GetMapping("/layers")
    public String layers(ModelMap mmap) {
        return prefix + "/layers";
    }

    /**
     * 官网首页
     */
    @GetMapping("/contactUs")
    public String contactUs(ModelMap mmap) {
        return prefix + "/contactUs";
    }


}
